cd %~dp0

set head=120
set foot=200

set dir=a
set p=D:\0\ffmpeg\bin

md %dir%

setlocal ENABLEDELAYEDEXPANSION

for %%i in (*.mp4) do (
%p%\ffprobe.exe "%%i" 2>&1 | findstr Duration >a.txt

FOR /F "tokens=2" %%j IN (a.txt) DO set a=%%j

set h=!a:~0,2!
if "!h:~0,1!" == "0" ( set h=!h:~1,2! )

set m=!a:~3,2!
if "!m:~0,1!" == "0" ( set m=!m:~1,2! )

set s=!a:~6,2!
if "!s:~0,1!" == "0" ( set s=!s:~1,2! )

set hs=!a:~9,2!
if "!hs:~0,1!" == "0" ( set hs=!hs:~1,2! )

set /a d=!h!*3600+!m!*60+!s!- %head%- %foot%

%p%\ffmpeg.exe -ss %head% -t !d!.!hs! -i %%i -vcodec copy -acodec copy %dir%\%%i
)

del a.txt


pause
